#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <assert.h>
#include <time.h>
#include <math.h>
#include <malloc.h>

#include "disposition.h"


void diInit(Dispo* terrain)
{
	int x,y;


	const char terrain_defaut[30][52] = {
		"####################################################",
		"#..................................................#",
		"#..................................................#",
		"#...................CCCCCCCC.......................#",
		"#..................................................#",
		"#..................................................#",
		"#..................................................#",
		"#..................................................#",
		"#..................................................#",
		"#..................................................#",
		"#..................................................#",
		"#..................................................#",
		"#..................................................#",
		"#..................................................#",
		"#..................................................#",
		"#..................................................#",
		"#..................................................#",
		"#..................................................#",
		"#..................................................#",
		"#..................................................#",
		"#..................................................#",
		"#..................................................#",
		"#..................................................#",
		"#..................................................#",
		"#..................................................#",
		"#..................................................#",
		"#..................................................#",
		"#..................................................#",
		"#..................................................#",
		"####################################################",

    };

	terrain->dimx = 30;
	terrain->dimy = 52;

	terrain->tab = (char **)malloc(sizeof(char *)*terrain->dimy);
	for (x=0; x<terrain->dimx; x++)
		terrain->tab[x] = (char *)malloc(sizeof(char)*terrain->dimy);

	for(x=0;x<terrain->dimx;++x)
		for(y=0;y<terrain->dimy;++y)
			terrain->tab[x][y] = terrain_defaut[x][y];

}

void diLibere(Dispo* terrain)
{
	int x;

	for (x=0; x<terrain->dimx; x++)
		free(terrain->tab[x]);
	free(terrain->tab);

	terrain->dimx = 0;
	terrain->dimy = 0;
	terrain->tab = NULL;
}

const char diTer_GetXY(const Dispo *terrain, const int x, const int y)
{
    assert (x < terrain->dimx);
    assert (y < terrain->dimy);
	return terrain->tab[x][y];
}

const int diGet_DimX(const Dispo *terrain)
{
	return terrain->dimx;
}

const int diGet_DimY(const Dispo *terrain)
{
	return terrain->dimy;
}

